﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using MyExtensions;

namespace Labs.Entity
{
    public abstract class TaxEntity : IPayable
    {
        private string name;
        private string taxid;

        public TaxEntity(string name)
            : this (name, "")
        { }
        public TaxEntity(string name, string taxid)
        {
            Name = name;
            TaxId = taxid;
        }

        public string Name
        {
            get { return name; }
            set 
            {
                if (value != null && value.Matches(@"^[\w\s]{4,30}$"))
                    name = value;
                else
                    throw new ArgumentException();
            }
        }
        public string TaxId
        {
            get { return taxid; }
            set {
                if (value != null &&
                    Regex.IsMatch(value, TaxIdRegex))
                    taxid = value;
                else
                    throw new ArgumentException();
            
            }
        }

        public abstract string TaxIdRegex { get; }

        abstract public decimal Pay();
 
    }
}
